package com.tencent.wxcloudrun.controller;

import com.tencent.wxcloudrun.model.City;
import com.tencent.wxcloudrun.response.R;
import com.tencent.wxcloudrun.service.CityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * ClassName: CityController
 * Package: com.tencent.wxcloudrun.controller
 * Description:
 *
 * @Date: 2023/1/22 8:34 AM
 * @Author: wht
 */
@Slf4j
@RestController
//@RestController = @Controller + @ResponseBody
@RequestMapping("/admin")
public class CityController {
    @Autowired
    CityService cityService;

    @PutMapping("/addOneCity")
    public <T> R<T> addOneCity(@RequestBody City city) {
        cityService.addOneCity(city);
        return R.successMsg("添加成功！");
    }

    @PatchMapping("/updateOneCityById")
    public <T> R<T> updateOneCityById(@RequestBody City city) {
        cityService.updateOneCityById(city);
        return R.successMsg("修改成功！");
    }

    @PostMapping("/getCityList")
    public <T> R<T> getCityList(@RequestBody City city) {
        List<City> cities = cityService.getCityList(city);
        return R.successData(cities);
    }
//    @GetMapping("/getAllCities")
//    public <T> R<T> getAllCities() {
//        List<City> cities = cityService.getAllCities();
//        return R.successData(cities);
//    }
//
//    @GetMapping("/getOneCityById/{id}")
//    public <T> R<T> getOneCityById(@PathVariable("id") Integer id) {
//        City city = cityService.getOneCityById(id);
//        return R.successData(city);
//    }

}
